Back - C Language MST-1 Solution By Vivek Sir email: vivekdubey22@gmail.com (w) 9826424484

C Language Video

Q1 Explain functions with an example : scanf(), printf(), pow(), getch()

scanf() function is used to take input from the user through keyboard.

#include <stdio.h>

void main()

    {

        int testInteger;

        printf("Enter an integer: ");

        scanf("%d", &testInteger); 

        printf("Number = %d",testInteger);

    }

 

printf() function is used to display output on the screen to the user.

#include <stdio.h>   

void main()

    {          int testInteger = 5; float number1 = 13.5; char chr = 'a';

                printf("Number = %d", testInteger);

printf("number1 = %f\n", number1);

printf("character = %c.", chr);

                // Displays the string inside quotations

                printf("C Programming");

    }

 

pow() function is used to get power of a value i.e. c = ab

Syntax of pow() in C language, double pow(double val1, double val2);

#include<stdio.h>

#include<math.h>

void main() {

   double x = 5.0;

   double y = 4.0;

   double p;

   p = pow(x, y);

   printf("The value : %lf", p);

}

 

getch() function is used to take input a character from the user through keyboard without echo. It can be used to hold program execution.

 

#include <stdio.h>

void main()

{

/* Our first simple C basic program */

    printf("Hello World! ");

    getch();

 }

Back - C Language MST-1 Solution By Vivek Sir email: vivekdubey22@gmail.com (w) 9826424484

C Language Video